package entities;

import util.DataVerify;

public class Product 
{
	
	private Long product_id;
	private Float stock_price;
	private String dateAdded;
	private String title;
	private String duration;
	private String productionDate;
	private String format;
	private int stockQty;
	private String img;
	private String price;
	
	
	
	public Product() {
	}

	public Product(Long product_id, String price, String dateAdded,
			String title, String duration, String productionDate,
			String format, int stockQty, String img) {
		super();
		this.product_id = product_id;
		this.stock_price = Float.valueOf(price);
		this.dateAdded = dateAdded;
		this.title = title;
		this.duration = duration;
		this.productionDate = productionDate;
		this.format = format;
		this.stockQty = stockQty;
		this.img = img;
		this.price = price;
	}

	public String getImg() {
		return img;
	}

	public void setImg(String img) {
		this.img = img;
	}
	
	public Long getProduct_id() {
		return product_id;
	}

	public void setProduct_id(Long product_id) {
		this.product_id = product_id;
	}
	public String getPrice() {
		return price;
	}

	public void setPrice(String price) {
		this.price = price;
	}
	public Float getStock_price() {
		return stock_price;
	}

	public void setStock_price(Float stock_price) {
		this.stock_price = stock_price;
	}

	public String getDateAdded() {
		return dateAdded;
	}

	public void setDateAdded(String dateAdded) {
		this.dateAdded = dateAdded;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDuration() {
		return duration;
	}

	public void setDuration(String duration) {
		this.duration = duration;
	}

	public String getProductionDate() {
		return productionDate;
	}

	public void setProductionDate(String productionDate) {
		this.productionDate = productionDate;
	}

	public String getFormat() {
		return format;
	}

	public void setFormat(String format) {
		this.format = format;
	}

	public int getStockQty() {
		return stockQty;
	}

	public void setStockQty(int stockQty) {
		this.stockQty = stockQty;
	}
	
	public static Product newInstance(Long product_id, String price, String dateAdded,
			String title, String duration, String productionDate,
			String format, int stockQty, String img){
		DataVerify.verifyObject("productid",product_id);
		DataVerify.verifyObject("stockprice",Float.valueOf(price));
		DataVerify.verifyObject("dateadded",dateAdded);
		DataVerify.verifyObject("title",title);
		DataVerify.verifyObject("duration",duration);
		DataVerify.verifyObject("productionDate",productionDate);
		DataVerify.verifyObject("format",format);
		DataVerify.verifyObject("stockQty",stockQty);
		DataVerify.verifyObject("img",img);
		DataVerify.verifyObject("price",price);
		
		
		return new Product(product_id, price, dateAdded,
				title, duration, productionDate,
				format, stockQty, img);
	}


	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Product other = (Product) obj;
		if (dateAdded == null) {
			if (other.dateAdded != null)
				return false;
		} else if (!dateAdded.equals(other.dateAdded))
			return false;
		if (duration == null) {
			if (other.duration != null)
				return false;
		} else if (!duration.equals(other.duration))
			return false;
		if (format == null) {
			if (other.format != null)
				return false;
		} else if (!format.equals(other.format))
			return false;
		if (product_id == null) {
			if (other.product_id != null)
				return false;
		} else if (!product_id.equals(other.product_id))
			return false;
		if (productionDate == null) {
			if (other.productionDate != null)
				return false;
		} else if (!productionDate.equals(other.productionDate))
			return false;
		if (stockQty != other.stockQty)
			return false;
		if (stock_price == null) {
			if (other.stock_price != null)
				return false;
		} else if (!stock_price.equals(other.stock_price))
			return false;
		if (title == null) {
			if (other.title != null)
				return false;
		} else if (!title.equals(other.title))
			return false;
		return true;
	}
	
	
}
